<!-- 交付预约申请 -->
<template>
	<view>
		<view class="block__title">交付预约信息</view>
		
<!-- 		<view class="cu-form-group">
			<view class="title">身份类型</view>
			<picker bindchange="PickerChange" :value="identityTypeIndex" :range="identityType" :range-key="'name'" @change="identityType">
				<view class="picker">
					{{identityType[identityTypeIndex].name}}
				</view>
			</picker>
		</view> -->
		
		<view class="cu-form-group">
			<view class="title">小区</view>
			<picker bindchange="PickerChange" :value="repairScopeIndex" :range="repairScopes" :range-key="'name'" @change="repairScopeChange">
				<view class="picker">
					{{repairScopes[repairScopeIndex].name}}
				</view>
			</picker>
		</view>
		
		<view class="cu-form-group">
			<view class="title">房号</view>
			<picker bindchange="PickerChange" :value="homeNumberIndex" :range="homeNumber" :range-key="'numdata'" @change="houseNumber">
				<view class="picker">
					{{homeNumber[homeNumberIndex].numdata}}
				</view>
			</picker>
		</view>
		
		
		<view class="cu-form-group">
			<view class="title">手机号</view>
			18298954865
		</view>
		<view class="cu-form-group">
			<view class="title">身份证号</view>
			612525188845625871
		</view>
		
		<view class="cu-form-group">
			<view class="title">日期</view>
			2022-02-12
		</view>
		
		<view class="cu-form-group margin-top">
			<textarea v-model="context" placeholder="备注..."></textarea>
		</view>
		
		<view class="bottomRegion">
				<button @click="vacantHouse" type="primary">提交申请</button>
		</view>
	</view>
</template>

<script>
	// pages/my/myHouseDetail.js
	import context from '../../lib/java110/Java110Context.js';
	const factory = context.factory;

	export default {
		data() {
			return {
				// phoneNumber:'18298954865',
				// idCard:'612525188845625871',
				context: '', //备注
				startDate: '请选择',
				endDate: '请选择',
				repairScopes: [{
						id: '001',
						name: '小区'
					},
					{
						id: '002',
						name: '小区'
					},
					{
						id: '003',
						name: '小区'
					},
					{
						id: '004',
						name: '小区'
					}
				],
				homeNumber:[{
					id: '001',
						numdata: '1001'
					},
					{
						id: '002',
						numdata: '1002'
					},
					{
						id: '003',
						numdata: '1003'
					},
					{
						id: '004',
						numdata: '1004'
					}
				],
				// identityType:[{
				// 	id: '001',
				// 		name: '业主'
				// 	},
				// 	{
				// 		id: '002',
				// 		name: '业主家人'
				// 	},
				// 	{
				// 		id: '003',
				// 		name: '租户'
				// 	}
				// ],
				// identityTypeIndex:0,
				homeNumberIndex:2,
				repairScopeIndex: 0,
				ownerInfo: {},
				// 用户信息
				userInfo: {},
				// 用户信息
				ownerFlag: false,
				// 是否有业主信息 标记 如果有为 true  没有为false
				roomDetail: {}
			};
		},

		components: {},
		props: {},

		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function(options) {
			// console.log(options.ok)
			// let _that = this;
			context.onLoad(options);
			this.roomDetail = JSON.parse(options.room);
			console.log("applyData.roomDetail",this.roomDetail)
			_that.loadOwenrInfo();
		},

		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function() {},

		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {},

		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},

		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},

		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh: function() {},

		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {},

		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {},
		methods: {
			repairScopeChange: function(e) {
				console.log('改变费用完成')
				this.repairScopeIndex = e.target.value //取其下标
			},
			houseNumber: function(e) {
				console.log('改变费用完成')
				this.homeNumberIndex = e.target.value //取其下标
			},
			// identityType: function(e) {
			// 	console.log('改变费用完成')
			// 	this.identityTypeIndex = e.target.value //取其下标
			// },
			// 预约起始日期
			startDateChange: function(e) {
				this.startDate = e.detail.value
			},
			// 预约结束日期
			endDateChange: function(e) {
				this.endDate = e.detail.value
			},
			// 提交申请
			vacantHouse: function(e) {
				console.log('this',this);
				let obj = {
					"homeNumberIndex": this.homeNumberIndex,
					"repairScopeIndex": this.repairScopeIndex
					// "identityTypeIndex":this.identityTypeIndex
				}
					console.log("提交数据", obj);
					context.request({
						url: constant.url.saveOwner,
						header: context.getHeaders(),
						method: "POST",
						data: obj,
						// data:obj, //动态数据
						success: function(res) {
							console.log(res, 99999);
							if (res.statusCode == 200 && res.data.code == 0) {
								uni.hideLoading();
								uni.navigateBack();
								return;
							}
							uni.hideLoading();
							uni.showToast({
								title: res.data.msg,
								icon: 'none',
								duration: 2000
							});
						},
						fail: function(e) {
							uni.hideLoading();
							uni.showToast({
								title: "服务器异常了",
								icon: 'none',
								duration: 2000
							})
						}
					})
			}
		}
	};
</script>
<style scoped lang="scss">
	@import "@/pagesB/my/myHouseDetail.css";
	text {
		text-align: center;
	}
	.block__title {
		margin: 0;
		font-weight: 400;
		font-size: 14px;
		color: rgba(69, 90, 100, .6);
		padding: 40rpx 30rpx 20rpx;
	}
	.bottomRegion{
		width: 100%;
		height: 100rpx;
		position: fixed;
		bottom: 0rpx;
		display: flex;
		justify-content: center;
		align-items: center;
			button{
				margin: 15rpx;
				width: 400rpx;
				height: 70rpx;
				border-radius: 40rpx;
				font-size: 26rpx;
				line-height: 70rpx;
			}
	}
</style>
